package com.example.day09question.modle;

import com.example.day09question.bean.RvBean;
import com.example.day09question.net.HttpUtil;
import com.example.day09question.net.ResultCallBack;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.observers.ResourceObserver;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by 阿炜啊 on 2020/7/15.
 */

public class MainPageModel {


   public void getData(final ResultCallBack callBack) {

       HttpUtil.getInstance()
               .getWanService()
               .getdatas(294)
               .subscribeOn(Schedulers.io())
               .observeOn(AndroidSchedulers.mainThread())
               .subscribeWith(new ResourceObserver<RvBean>() {
                   @Override
                   public void onNext(RvBean rvBean) {
                       callBack.onSuccess(rvBean);
                   }

                   @Override
                   public void onError(Throwable e) {
            callBack.onFail(e.toString());
                   }

                   @Override
                   public void onComplete() {

                   }
               });


    }


}
